package com.tianbao54.kotlin_01

fun main(args: Array<String>) {

    println(myPrint("hel"))
    println(myPrint("hello"))

    var a = 6

    var result = when (a) {
        1 -> {
            println("a = $a")
            10
        }
        2 -> {
            println("a = $a")
            20
        }
        3, 4, 5, 6 -> {
            println("a = 3 or 4 or 5 or 6")
            30
        }
        in 6..10 -> {
            println("a is range of 6 , 10")
            40
        }
        else -> {
            println("other number")
            50
        }
    }
    println("result = $result")
}

fun myPrint(str: String): String {

    return when (str) {
        "hello" -> str.toUpperCase()
        "world" -> str.toUpperCase()
        "hello world" -> str.toUpperCase()
        else -> "other input"
    }
}

fun myPrint2(str: String): String =
        when (str) {
            "hello" -> str.toUpperCase()
            "world" -> str.toUpperCase()
            "hello world" -> str.toUpperCase()
            else -> "other input"
        }